
class Animal{
    public String name;
    public int age ;
    public String color;
    //自己写的父类构造方法
    public Animal(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
        System.out.println("父类的构造方法！");
    }
    static{
        System.out.println("Animal:父类静态代码块执行");
    }
    {
        System.out.println("Animal:父类实例代码块执行");
    }

    public void eat(){
        System.out.println(this.name+"正在吃饭！");
    }
}
//Dog子类 继承了 Animal父类
class Dog extends Animal{
    public Dog(){
        super("旺财",3,"黄色");
    }

    public Dog(String name, int age, String color) {
        super(name, age, color);
    }
}

//Cat子类 继承了 Animal父类
class Cat extends Animal{
    public Cat(String name, int age, String color) {
        super(name, age, color);
        System.out.println("子类构造方法！");
    }
    static{
        System.out.println("Cat:子类静态代码块执行");
    }
    {
        System.out.println("Cat:子类实例代码块执行");
    }


    public void miao(){
        System.out.println(this.name+"正在喵喵喵~");
    }
}

public class Test {
    public static void main(String[] args) {
        Cat cat=new Cat("困困",3,"白色");
        System.out.println("--------------------------");
        Cat cat2=new Cat("困困",3,"白色");
/*        cat.eat();
        cat.miao();*/
    }
}
